from collections import deque

def bfs(rooms, start, boss):
    visited = set()
    queue = deque([(start, 0)])
    prev = {start: None}  # 存储前驱节点

    while queue:
        room, steps = queue.popleft()
        if room == boss:
            # 重构路径
            path = []
            while room is not None:
                path.append(room)
                room = prev[room]
            return list(reversed(path))  # 从开始节点到目标节点的路径

        visited.add(room)

        for direction in rooms[room]:
            next_room = rooms[room][direction]
            if next_room not in visited:
                queue.append((next_room, steps + 1))
                prev[next_room] = room  # 记录前驱节点

    return []  # 如果找不到路径到boss房间，则返回空列表

